package com.zjc.activiti;

import org.activiti.engine.*;
import org.junit.Test;

/**
 * Created by lv_03575 on 2018/4/8.
 */
public class JdbcActiviti {

    /**
     * 通过代码方式获取jdbc链接
     */
    @Test
    public  void getJdbc(){
        ProcessEngineConfiguration configuration=ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
        configuration.setJdbcDriver("com.mysql.jdbc.Driver");
        configuration.setJdbcUrl("jdbc:mysql://localhost:3306/activiti_test_db?useUnicode=true&characterEncoding=utf8");
        configuration.setJdbcUsername("root");
        configuration.setJdbcPassword("123456");
        configuration.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
        ProcessEngine processEngine= configuration.buildProcessEngine();
        System.out.println(processEngine);
    }

    /**
     * 通过配置文件获取数据库链接
     */
    @Test
    public  void getJdbcByXml(){
        ProcessEngine processEngine=ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml").buildProcessEngine();
        System.out.println(processEngine);
        RepositoryService repositoryService=processEngine.getRepositoryService();
        RuntimeService runtimeService=processEngine.getRuntimeService();
        TaskService taskService=processEngine.getTaskService();
    }
}
